﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Sumen.Business;
using DevExpress.XtraSplashScreen;
using Sumen.Library.Enum;

using Sumen.Business.Permission;
using Sumen.Business.Presenter.Inventory;
using Sumen.Library.Froms;


namespace Sumen.GUI.Inventory
{
    public partial class Frm_History_Product : XtraUserControlKira
    {

        private InventoryPresenter _inventoryPresenter;

        #region Form

        public Frm_History_Product()
        {
            InitializeComponent();
            FormCode = EnumFormCode.FrmHistoryProduct;
            buttonsArray1.capQuyen(new Permission(FormCode.ToString(), ClsPublic.User.User_Username));
            _inventoryPresenter = new InventoryPresenter();
            dateBegin.DateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            dateEnd.DateTime = dateBegin.DateTime.AddMonths(1).AddMinutes(-1);
        }

        #endregion


        #region Button event

        private void buttonsArray1_btnEventProduceReports_click(object sender, EventArgs e)
        {
            LoadForm();
        }

        private void buttonsArray1_btnEventClose_click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        #endregion


        #region Method

        public override void LoadForm()
        {
            List<object> id = popupTreeDM.ChildListPrimaryKey;
            //phải load hết category con
            gridControl1.DataSource = _inventoryPresenter.GetHistoryProduct(id, dateBegin.DateTime, dateEnd.DateTime).First();
            gridView1.BestFitColumns();
            gridView1.ExpandAllGroups();
        }

        #endregion

        











    }
}